package com.mecuros.gateway.config;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.mecuros.gateway.filter.CarlosRequestGlobalFilter;
import com.mecuros.gateway.filter.PasswordDecoderFilter;
import com.mecuros.gateway.handler.GlobalExceptionHandler;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;

/**
 * @author yujianbo
 * @Classname GatewayConfiguration
 * @Description 网关配置
 * @Date 2022/4/28 9:02 下午
 */
@Configuration(proxyBeanMethods = false)
@EnableConfigurationProperties(GatewayConfigProperties.class)
public class GatewayConfiguration {

    @Bean
    public PasswordDecoderFilter passwordDecoderFilter(GatewayConfigProperties configProperties) {
        return new PasswordDecoderFilter(configProperties);
    }

    @Bean
    public CarlosRequestGlobalFilter pigRequestGlobalFilter() {
        return new CarlosRequestGlobalFilter();
    }

//    @Bean
//    public PigSpringDocGlobalFilter pigSwaggerGlobalFilter() {
//        return new PigSpringDocGlobalFilter();
//    }
//
//    @Bean
//    public ValidateCodeGatewayFilter validateCodeGatewayFilter(GatewayConfigProperties configProperties,
//                                                               ObjectMapper objectMapper, RedisTemplate redisTemplate) {
//        return new ValidateCodeGatewayFilter(configProperties, objectMapper, redisTemplate);
//    }

    @Bean
    public GlobalExceptionHandler globalExceptionHandler(ObjectMapper objectMapper) {
        return new GlobalExceptionHandler(objectMapper);
    }

//    @Bean
//    public ImageCodeHandler imageCodeHandler(RedisTemplate redisTemplate) {
//        return new ImageCodeHandler(redisTemplate);
//    }

}

